 var xg = Ext.grid;
 var selectText_Pre = "";
var menu = new Ext.menu.Menu({
       items : [{
           id:'pr_Menu',
           text : "检索全文",
           iconCls: 'edit',
           handler:function (node){
                /*******更新检索值***/
                if(updateSm)
                   updateSm({value:selectText_Pre});
                updateTab(tabArray[1].id,{doClass:'original',searchMess:selectText_Pre});
          }
       }, {
           id:'tr_Menu',
           text : "方剂分析",
           iconCls: 'remove',
           handler:function (node){
                updateTab(tabArray[0].id,{preActiveTab:0,searchMess:selectText_Pre});

          }
       }, {
           id:'it_Menu',
           text : "中药信息",
           iconCls: 'add',
           handler:function (node){
           	 updateTab(tabArray[2].id,{traActiveTab:0,searchMess:selectText_Pre});
               
          }
       }]
    });
     Ext.get("prescriptions-body").on('contextmenu',function(e,e1,e2){
       	var str = getSelectedText();
       	if(str == '')
      		return;
      	selectText_Pre = str;
        menu.showAt(e.getXY());
    });
    
function getSelectedText() {
	if (window.getSelection) {
	// This technique is the most likely to be standardized.
	// getSelection() returns a Selection object, which we do not document.
		return window.getSelection().toString();
	
	}
	else if (document.getSelection) {
		// This is an older, simpler technique that returns a string
		return document.getSelection();
	}
	else if (document.selection) {
	// This is the IE-specific technique.
	// We do not document the IE selection property or TextRange objects.
	return document.selection.createRange().text;
	}

} 

////////////////////////////////////////////////////////////////////////////
    // example of custom renderer function
    function pctChange(val){

        var v = '</div><div style="word-wrap:break-word; overflow:hidden;" >' + val + '</div><div>';
     
        return v;
    }

   var storeContent = new Ext.data.JsonStore({
        root: 'articles',
        fields: [
            'id', 'text'
        ],
        // load using script tags for cross domain, if the data in on the same domain as
        // this page, an HttpProxy would be better
        proxy: new Ext.data.HttpProxy({
            url: basePath+'/../catalog',
            doClass:'content',
            chapterId:chapterId
        })
    });
    storeContent.setDefaultSort('id', 'asc');
/****
 var panel = new Ext.Panel({
        applyTo: 'grid-example',
      
        title:'Forum Search',
        height:300,
        autoScroll:true,

        items: new Ext.DataView({
            tpl: resultTpl,
            store: storeContent,
            itemSelector: 'div.search-item'
        }),

        tbar: [
            'Search: ', ' ',
            new Ext.app.SearchField({
                store: ds,
                width:320
            })
        ],

        bbar: new Ext.PagingToolbar({
            store: ds,
            pageSize: 20,
            displayInfo: true,
            displayMsg: 'Topics {0} - {1} of {2}',
            emptyMsg: "No topics to display"
        })
    });

****/

    // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: storeContent,
        shadow:true,
        autoScroll: true,
        columns: [
            {id:'AA',header: "条号", width: 90, sortable: true, dataIndex: 'id',menuDisabled:true},
            {header: "内容", css:'word-break：break-all',renderer:pctChange, sortable: true,id:'text',dataIndex: 'text',menuDisabled:true}
        ],
         iconCls:'icon-grid',
         bodyStyle:'width:100%;',
		 autoWidth:true,
	//	 height:500,
		 autoExpandColumn:'text',
        tools:[{
            id:'up',
            hidden:true,
            style:'float:left;align:"center"',
            handler: function(event, toolEl, panel){
        		storeContent.load({params:{doClass:"content", chapterId:this.value}});
        }},
        {
            id:'down',
            hidden:true,
            align:"center",
            handler: function(event, toolEl, panel){
           		 storeContent.load({params:{doClass:"content", chapterId:this.value}});
        		//updataCaContent({doClass:"content", chapterId:this.value});
        }}]
        ,
         height : Ext.get("content_div").getHeight()-70,
        title:' ',
        renderTo:'grid_content'
    });

  //  grid.render('grid_content');
   
    /****上下目录显示控制*******/
    storeContent.on("load",function(s,record,options){
		
    	if(s.reader.jsonData.hasnext)
    	{
    		grid.getTool('down').setVisible(true);
    		grid.getTool('down').value = s.reader.jsonData.nextid;
    	}
    	else 	
    		grid.getTool('down').setVisible(false);
    	
    	if(s.reader.jsonData.hasprevious){
    		grid.getTool('up').setVisible(true);
    		grid.getTool('up').value = s.reader.jsonData.previousid;
    	}else
    		grid.getTool('up').setVisible(false);
      
    });
    
    if(doClass_caContent == 'original'){
		 storeContent.load({params:{doClass:'original',searchMess:searchMess_caContent}});
	}else
		storeContent.load({params:{doClass:'content',chapterId:chapterId}});
    
    